package com.neusoft.base;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.io.Serializable;
import java.util.Collection;
import java.util.HashMap;
import java.util.Map;
import java.util.Set;

/**
 * Controller基类
 */
public class BaseController {

    protected Logger logger = LoggerFactory.getLogger(this.getClass());

    protected final static String DATE_FORMATE = "yyyy-MM-dd";

    // 下面是判断null的操作

    public boolean isEmpty(String str) {
        return (null == str) || (str.trim().length() <= 0);
    }

    public boolean isEmpty(Character cha) {
        return (null == cha) || cha.equals(' ');
    }

    public boolean isEmpty(Object obj) {
        return (null == obj);
    }

    public boolean isEmpty(Object[] objs) {
        return (null == objs) || (objs.length <= 0);
    }

    public boolean isEmpty(Collection<?> obj) {
        return (null == obj) || obj.isEmpty();
    }

    public boolean isEmpty(Set<?> set) {
        return (null == set) || set.isEmpty();
    }

    public boolean isEmpty(Serializable obj) {
        return null == obj;
    }

    public boolean isEmpty(Map<?, ?> map) {
        return (null == map) || map.isEmpty();
    }

    /**
     * 获得map
     *
     * @return
     */
    public Map<String, Object> getMap() {
        return new HashMap<String, Object>();
    }
}
